package com.example.shengyin.frontController;//package com.example.shengyin.frontController;
//
//import com.alibaba.fastjson2.JSON;
//import com.example.shengyin.entity.Admin;
//import com.example.shengyin.entity.Article;
//import com.example.shengyin.entity.Page;
//import com.example.shengyin.service.ArticleService;
//import com.example.shengyin.util.Result;
//import com.example.shengyin.util.StrUtil;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.format.annotation.DateTimeFormat;
//import org.springframework.validation.BindingResult;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.validation.Valid;
//import java.sql.Timestamp;
//import java.util.*;
//
//
//@RestController
//@RequestMapping("/front/article")
//@Validated
//@CrossOrigin(origins = "*", maxAge = 3600,allowCredentials="true")
////swagger
//@Api("article表管理")
////redis缓存用
//public class FrontArticleController
//{
//    @Autowired
//    private ArticleService service;
//    @Autowired
//    private RedisTemplate redisTemplate;
//    public Map ReMap(){
//        Map<String,List<String>> map=new HashMap<>();
//        map.put("公司简介",new ArrayList<>(Arrays.asList("公司简介")));
//        map.put("媒体报道",new ArrayList<>(Arrays.asList("媒体报道")));
//        map.put("交流合作",new ArrayList<>(Arrays.asList("交流合作")));
//        map.put("大事记",new ArrayList<>(Arrays.asList("大事记")));
//        map.put("公司新闻",new ArrayList<>(Arrays.asList("开业活动","国际交流","员工活动","亲子活动","公益讲座","公益活动","家长培训","社会关注","全部")));
//        map.put("活动讲座",new ArrayList<>(Arrays.asList("热门推荐","专题精选","门店信息")));
//        map.put("言语科普",new ArrayList<>(Arrays.asList("言语科普")));
//        map.put("课程介绍",new ArrayList<>(Arrays.asList("课程介绍")));
//        return map;
//    }
//
//    @ApiOperation("分页查询")
//    @GetMapping("/list")
//    public Result list(Page page, @ApiParam(name = "type",value = "分类") @RequestParam(required = false) String type,
//                       @ApiParam(name = "typecode",value = "分类编码") @RequestParam(required = false) String typecode,
//                       @ApiParam(name = "createby",value = "创建人") @RequestParam(required = false) String createby,
//                       @ApiParam(name = "starttime",value = "类别创建时间的起始值")@DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam(required =
//                               false) Date starttime,
//                       @ApiParam(name = "endtime",value = "类别创建时间的结束值")@DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam(required =
//                               false) Date endtime)
//    {
//        Timestamp start=StrUtil.toTimestamp(starttime);
//        Timestamp end=StrUtil.toTimestamp(endtime);
//        System.out.println("page:"+page);
//        List<Article> list = service.articleList(page,type,typecode,createby,start,end);
//        int count = service.countTotall(type,typecode,createby,start,end);
//        if(count==0||list==null)
//            return Result.error(null);
//        page.setData(list);
//        page.setCount(count);
//        System.out.println(JSON.toJSONString(Result.success(page)));
//        return Result.success(page);
//    }
//    @ApiOperation("单个查找")
//    @GetMapping(value = "/select/{id}")
//    public Result select(@PathVariable(value = "id") Long id)
//    {
//        Article article = service.selectById(id);
//        System.out.println(JSON.toJSONString(article));
//        if(article==null)
//            return Result.error("没有找到数据");
//        return Result.success(article);
//    }
//
//
//
//    @ApiOperation("首页-》公司新闻，讲座，交流合作，媒体报道")
//    @GetMapping(value = "/findindexArticle/{name}/{number}")
//    public Result select2(@PathVariable(value = "name") String name,@PathVariable(value = "number") int number)
//    {
//        List<Article> articles = service.articleList(new Page(1, number), null, name, null, null, null);
//        return Result.success(articles);
//    }
//
//    @ApiOperation("关于我们-》公司简介")
//    @GetMapping(value = "/findCompInfo")
//    public Result select3()
//    {
//        List<Article> articles = service.articleList(new Page(1, 1), null, "公司简介", null, null, null);
//        return Result.success(articles);
//    }
//
//    @ApiOperation("关于我们-》媒体报道")
//    @GetMapping(value = "/findNews/{page}/{limit}")
//    public Result select4(@PathVariable(value = "page") int page,@PathVariable(value = "limit") int limit)
//    {
//        Page page1 = new Page(page, limit);
//        List<Article> articles = service.articleList(page1, null, "媒体报道", null, null, null);
//        int count = service.countTotall(null, "媒体报道", null, null, null);
//        if(count==0||articles==null)
//        {
//            return Result.success(page1);
//        }
//        page1.setCount(count);
//        page1.setPageTotal(count);
//        page1.setData(articles);
//        return Result.success(page1);
//    }
//
//
//
//
////    @ApiOperation("XXXX(热文，最新，家长推荐")
////    @GetMapping(value = "/kepu/{number}")
////    public Result selectXXXX(@PathVariable(value = "number") int number)
////    {
////        Map map=new HashMap<>();
////        return Result.success(map);
////    }
//
//
//}
